/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bus;

import dal.DBConnection;
import entity.Product;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author TRGOAT
 */
public class ProductManager {
    public List<Product> getAll() {
        try {
            List<Product> list = new ArrayList<Product>();
            Connection con = new DBConnection().getConnection();
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("select * from Product");
            Product p;
            while (rs.next()) {
                p = new Product();
                p.setId(rs.getInt(1));
                p.setName(rs.getString(2));
                p.setAuthor(rs.getString(3));
                list.add(p);
            }
            return list;
        } catch (SQLException ex) {
            Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    public void addProduct(int id, String name, String author){
    int ID;
    String Name;
    String Author;
    
    }
}
